function moduleAntispamIPInterdits()
{
	this.supprimerIP = function(ip)
	{
		cp.ajaxService({
			action:				'cp-antispamIPInterdits-supprimerIP',
			regle_id:			$(ip).attr('name')
		}, function(reponse) {
			$(ip).parent().parent().supprimerAvecEffet();
		});	
	};
	
	this.ajouterIP = function()
	{

		cp.ajaxService({
			action:				'cp-antispamIPInterdits-ajouterIP',
			ip:					$('#ip').val()
		}, function(reponse) {
			
			$('#listeIP>tbody').append(
				'<tr>'+
					'<td style="width:90%;">&nbsp;</td>'+
					'<td style="width:10%;"><a href="#" class="supprimerIP" name="'+$('regle_id', reponse).text()+'"><img src="images/16/supprimer.png" alt="'+cp.msg.supprimer+'" title="'+cp.msg.supprimer+'" /></a></td>'+
				'</tr>'
			).find('tr:last').find('td:first').text($('pattern', reponse).text());
				
			$('#divIP').animate({scrollTop: $('#divIP')[0].scrollHeight});
			$('#listeIP>tbody').find('tr:last')
				.css('background', '#85D985')
				.animate({ backgroundColor:'#FFFFFF'}, 1500);
			
			$('#ip').val('');
			
		});
		
	};
}

mAntispamIPInterdits = new moduleAntispamIPInterdits();

$(document).ready(function() {
	
	$('a.supprimerIP').live('click', function() {
		if(confirm(cp.msg.antispam_retirer_ip)) {
			mAntispamIPInterdits.supprimerIP(this);
		}
		return false;
	});
	
	$('#formAjouterIP').submit(function() {
		mAntispamIPInterdits.ajouterIP();
		return false;
	});
	
});